package org.example.test.service;

import org.example.test.entity.User;
import org.example.test.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserService {
    @Autowired
    private UserMapper userMapper;
    public int save(User user){
        if (user.getId()==null){//user没有id则表示是新增，有id就是更新呗！
            return userMapper.insert(user);
        }
        else{
           return userMapper.update(user);
        }
    }
}
